import {baseEffects, baseReducers, baseState} from "../../../models/baseModel";
import * as request from "../../../services/CommonHttpService";
import AppService from "../../../common/AppService";
import pageHelper from "utils/pageHelper";
export default {
  namespace: 'bpSession',

  state: {
    ...baseState,
  },

  reducers: {
    ...baseReducers
  },

  effects: {

    ...baseEffects,

    // 获取血压设备列表
    * getPageInfo({payload}, {call, put}) {
      console.log(payload)
      const p = {
        ...payload,
        server: AppService.deviceUrl,
        baseUrl: getBaseUrl(),
        process: (records) => {
          return pageHelper.noPage(records,payload.page.pageSize);
        }
      }
      yield put({
        type: 'baseGetPageInfo',
        payload: p
      });
    },

    // 保存和修改
    * save({payload}, {put}) {

      yield put({
        type: 'baseSave',
        payload: {...payload, baseUrl: getBaseUrl()}
      });
    },


    // 删除 之后查询分页
    * delete({payload}, {call, put, select}) {

      yield put({
        type: 'baseDelete',
        payload: {...payload, baseUrl: getBaseUrl()}
      });
    }
  }

}

function getBaseUrl() {
  return "/device/bp/online";
}

